import Vue from 'vue'
import Router from 'vue-router'
import {constantRoutes} from "@/router/constantRoutes";
import {asyncRoutes} from "@/router/asyncRoutes";

Vue.use(Router)

import Layout from '@/layout'


const createRouter = () => new Router({
  mode: 'history',
  scrollBehavior: () => ({y: 0}),
  routes: [...constantRoutes, ...asyncRoutes]
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
